package org.example;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-11-05
 * 22:28
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[] arr=new int[6];
        for (int i = 0; i < 6; i++) {
            arr[i]=sc.nextInt();
        }
        String s= sc.nextLine();
        String ss=sc.nextLine();
        String[] ss1=ss.split("");
        int[] sn={arr[0],arr[1],arr[5],arr[4]};
        int[] we={arr[0],arr[3],arr[5],arr[2]};
        int indexsn=0;
        int indexwe=0;
        for (int i = 0; i < ss1.length; i++) {
            switch (ss1[i]){
                case "S":indexsn-=1;
                if(indexsn<0){
                    indexsn=5;
                }
                break;
                case "N":indexsn=(indexsn+1)%we.length;
                break;
                case "w":indexwe-=1;
                if(indexwe<0){
                    indexwe=5;
                }
                break;
                case "E":indexwe=(indexwe+1)%we.length;
            }
        }
        if(ss1[ss1.length-1].equals("S")||ss1[ss1.length-1].equals("N")){
            System.out.println(sn[indexsn]);
        }else{
            System.out.println(we[indexwe]);
        }
    }
}
